/*
 * PlayGame.cpp
 *
 *  Created on: Nov 18, 2010
 *      Author: timmeh
 */

#define res SDLResource::Instance()

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <iostream>
#include "SDLResource.h"
#include "SDLFactory.h"
#include "Ball.h"
#include "SDLBall.h"
#include "Entity.h"
#include "Level.h"
#include <time.h>
#include <unistd.h>
#include "LevelGenerator.h"
#include "SDLLevelGenerator.h"
#include "Stopwatch.h"
#include "Game.h"
#include "SDLPlayer.h"

using namespace std;
using namespace bo_sdl;

int main(int argc, char* argv[]){
	int xScreen = 800;
	int yScreen = 600;
	if ( argc == 3 ){
		// If screensize arguments found: Put them in xScreen and yScreen, otherwise: use default 800:600
		xScreen = atoi(argv[1]);
		yScreen = atoi(argv[2]);
		if ( (double)xScreen / (double)yScreen != 4.0/3.0 ){
			// If not correct ratio: use default 800x600
			cout << "Incorrect argument ratio! Reverting to default 800x600" << endl;
			xScreen = 800;
			yScreen = 600;
		}
	}
	// Init the screen (has to be done only once)
	double scale = xScreen/8;
	res->Initialize(xScreen, yScreen, scale);
	res->SetBackground("background.jpg");
	// Scale which every coord has to be multiplied with
	SDLFactory* fact = new SDLFactory;
	SDLLevelGenerator* gen = new SDLLevelGenerator(fact);
	int fps = 120;
	SDLPlayer* player = new SDLPlayer("Timmy", 5);
	Game* gameObj = new Game(fact, gen, fps, 5, player);
	gameObj->GenStdGame("Paddle2Dark.png", "ball.png", "Breakable2XSF.png");
	gameObj->GenStdGame("paddle.png", "ball.png", "breakablesmall.png");
	gameObj->Run();

}

